package com.ldu.dao.impl;

import com.ldu.dao.query.support.PageResult;
import com.ldu.dao.dataobject.CartDO;
import com.ldu.dao.query.CartQuery;
import com.ldu.dao.mapper.ext.CartExtMapper;
import com.ldu.dao.intf.CartManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for Cart.
 */

@Component
public class CartManagerImpl implements CartManager{

    
    @Autowired
    protected CartExtMapper cartExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(CartQuery query){
        return cartExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(CartQuery query){
        return cartExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(CartDO record){
        return cartExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(CartDO record){
        return cartExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<CartDO> selectByQuery(CartQuery query){
        return cartExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<CartDO> selectByQueryWithPage(CartQuery query) {
        PageResult<CartDO> result = new PageResult<CartDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public CartDO selectByPrimaryKey(Long id){
        return cartExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( CartDO record,  CartQuery query){
        return cartExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( CartDO record,  CartQuery query){

        return cartExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(CartDO record){
        return cartExtMapper.updateByPrimaryKeySelective(record);
    }
}